package com.atguigu.reggie.service.impl;

import com.atguigu.reggie.common.BaseContext;
import com.atguigu.reggie.entity.ShoppingCart;
import com.atguigu.reggie.mapper.ShoppingCartMapper;
import com.atguigu.reggie.service.ShoppingCartService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * @author Luo Sheng
 * @school YiBin university
 * @create 2022-10-25 10:46
 */
@Service
public class ShoppingCartServiceImp extends ServiceImpl<ShoppingCartMapper, ShoppingCart> implements ShoppingCartService {
    @Override
    public void clean() {
        // 创建查询构造器
        LambdaQueryWrapper<ShoppingCart> shoppingCartLambdaQueryWrapper = new LambdaQueryWrapper<>();
        shoppingCartLambdaQueryWrapper.eq(ShoppingCart::getUserId, BaseContext.getCurrentId());

        // 执行SQL
        this.remove(shoppingCartLambdaQueryWrapper);
    }
}
